import axios from 'axios';

const apiClient = axios.create({
  baseURL: 'http://localhost:25080', // 确保与后端端口一致
  headers: {
    'Content-Type': 'application/json',
  },
});

export default {
  // 获取分类列表
  getCategories(name = '', page = 1, pageSize = 5) {
    return apiClient.get(`/category/page`, {
      params: { name, page, pageSize },
    });
  },

  // 添加分类
  addCategory(category) {
    return apiClient.post('/category/save', category);
  },

  // 更新分类
  updateCategory(category) {
    return apiClient.put('/category/update', category);
  },

  // 删除分类
  deleteCategory(id) {
    return apiClient.delete(`/category/remove/${id}`);
  },

  // 获取分类详情
  getCategoryDetails(id) {
    return apiClient.get(`/category/${id}`);
  },
};